<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <script src="../js/vue.js"></script>
    <script src="../element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f4;
        }
        .login-container {
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
            width: 350px;
            text-align: center;
        }
        .login-container h2 {
            margin-bottom: 20px;
            color: #333;
        }
        .login-container input[type="text"],
        .login-container input[type="password"] {
            width: calc(100% - 22px);
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .login-container input[type="button"] {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .login-container input[type="button"]:hover {
            background-color: #0056b3;
        }
        #toRegis{
            height: 50px;
            text-align: left;

        }
    </style>
</head>

<body>
<div id="loginDiv" style="height: 350px">
    <div class="login-container">
        <h2>医院挂号系统登录</h2>
        <form>
            <input type="text" name="username" placeholder="请输入账号" v-model="user.accountNum" required>
            <input type="password" name="password" placeholder="请输入密码" v-model="user.pwd" required>
            <div id="toRegis">
                <a href="userRegister.html">没有账号？注册一个</a>
            </div>

            <input type="button" value="登录" @click="login">
        </form>
    </div>
</div>



<script>
    new Vue({
        el:"#loginDiv",
        data() {
            return{
                user:{
                    pwd:'',
                    accountNum:''
                }
            }
        },
        methods: {
            login() {

                axios.post("http://localhost:8080/users/login",this.user).then(resp=>{
                    if(resp.data.msg === "success"){
                        this.user = resp.data.data;
                        this.$message.success("登录成功");
                        document.location="userFrame.html"
                    }else{
                        this.$message.error("登录失败");
                    }
                })
            },
        }

    })
</script>



</body>
</html>